﻿<%@ WebHandler Language="C#" Class="delete" %>

using System;
using System.Web;

public class delete : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        if (!string.IsNullOrEmpty(context.Request.QueryString["id"].ToString())&& context.Request.QueryString["img"] != null)
        {
            int id = Convert.ToInt32(context.Request.QueryString["id"]);
            string img = context.Request.QueryString["img"].ToString();
            BLL.LostAndFound bllLAF = new BLL.LostAndFound();
            if (bllLAF.softDelByLId(id))
            {
                if (img != "")
                {
                    if (common.deleteFile(img))
                    {
                        context.Response.Redirect(context.Request.UrlReferrer.ToString());
                    }
                    else
                    {
                        context.Response.Redirect(context.Request.UrlReferrer.ToString());
                    }
                }
                else
                {
                    context.Response.Redirect(context.Request.UrlReferrer.ToString());
                }
            }
            else
            {
                context.Response.Write("no");
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}